package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PopulationZhuxaio;
import com.ruoyi.system.service.IPopulationZhuxaioService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 户口注销Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/cz_zhuxaio")
public class PopulationZhuxaioController extends BaseController
{
    private String prefix = "system/cz_zhuxaio";

    @Autowired
    private IPopulationZhuxaioService populationZhuxaioService;

    @RequiresPermissions("system:cz_zhuxaio:view")
    @GetMapping()
    public String cz_zhuxaio()
    {
        return prefix + "/cz_zhuxaio";
    }

    /**
     * 查询户口注销列表
     */
    @RequiresPermissions("system:cz_zhuxaio:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PopulationZhuxaio populationZhuxaio)
    {
        startPage();
        List<PopulationZhuxaio> list = populationZhuxaioService.selectPopulationZhuxaioList(populationZhuxaio);
        return getDataTable(list);
    }

    /**
     * 导出户口注销列表
     */
    @RequiresPermissions("system:cz_zhuxaio:export")
    @Log(title = "户口注销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PopulationZhuxaio populationZhuxaio)
    {
        List<PopulationZhuxaio> list = populationZhuxaioService.selectPopulationZhuxaioList(populationZhuxaio);
        ExcelUtil<PopulationZhuxaio> util = new ExcelUtil<PopulationZhuxaio>(PopulationZhuxaio.class);
        return util.exportExcel(list, "户口注销数据");
    }

    /**
     * 新增户口注销
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存户口注销
     */
    @RequiresPermissions("system:cz_zhuxaio:add")
    @Log(title = "户口注销", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PopulationZhuxaio populationZhuxaio)
    {
        return toAjax(populationZhuxaioService.insertPopulationZhuxaio(populationZhuxaio));
    }

    /**
     * 修改户口注销
     */
    @RequiresPermissions("system:cz_zhuxaio:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PopulationZhuxaio populationZhuxaio = populationZhuxaioService.selectPopulationZhuxaioById(id);
        mmap.put("populationZhuxaio", populationZhuxaio);
        return prefix + "/edit";
    }

    /**
     * 修改保存户口注销
     */
    @RequiresPermissions("system:cz_zhuxaio:edit")
    @Log(title = "户口注销", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PopulationZhuxaio populationZhuxaio)
    {
        return toAjax(populationZhuxaioService.updatePopulationZhuxaio(populationZhuxaio));
    }

    /**
     * 删除户口注销
     */
    @RequiresPermissions("system:cz_zhuxaio:remove")
    @Log(title = "户口注销", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(populationZhuxaioService.deletePopulationZhuxaioByIds(ids));
    }
}
